package com.weike.wk_android;

import com.weike.wk_android.commons.UrlConstant;
import com.weike.wk_android.model.Register;
import com.weike.wk_android.model.UserInfo;
import com.weike.wk_android.utils.BaseResponse;
import com.weike.wk_android.model.Version;

import java.util.Map;

import io.reactivex.Observable;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.Headers;
import retrofit2.http.POST;
import retrofit2.http.Query;
import retrofit2.http.QueryMap;

public interface Api {
    @Headers({
            "hm-app: HMA",
            "hm-app-v: 3.5.1",
            "hm-app-m: Prod",
            "hm-app-c: UMeng",
            "hmyd-app-timestamp: 1552405982080"
    })
    @GET("app/version/v1/getLastVersion")
    Call<Version> getLastVersion();

    @Headers({
            "hm-app: HMA",
            "hm-app-v: 3.5.1",
            "hm-app-m: Prod",
            "hm-app-c: UMeng",
            "hmyd-app-timestamp: 1552405982080"
    })
    @GET("app/version/v1/getLastVersion")
    Observable<Version> getLastVersionWithRxJava();

    @Headers({
            "hm-app: HMA",
            "hm-app-v: 3.5.1",
            "hm-app-m: Prod",
            "hm-app-c: UMeng",
            "hmyd-app-timestamp: 1552405982080"
    })
    @GET("app/version/v1/getLastVersion")
    Observable<BaseResponse<Version>> getLastVersionWithRxJava2();


    @FormUrlEncoded
    @Headers({
            "hm-app: HMA",
            "hm-app-v: 3.5.1",
            "hm-app-m: Prod",
            "hm-app-c: UMeng",
            "hmyd-app-timestamp: 1552405982080"
    })
    @POST("app/user/v1/login")
    Call<UserInfo> login(@Field("username") String username, @Field("password") String password);

    @Headers({
            "hm-app: HMA",
            "hm-app-v: 3.5.1",
            "hm-app-m: Prod",
            "hm-app-c: UMeng",
            "hmyd-app-timestamp: 1552405982080"
    })
    @GET("app/user/v1/login")
//    Call<UserInfoModel> loginWithGet(@Query("username") String username, @Query("password") String password);
    Call<UserInfo> loginWithGet(@QueryMap Map<String, String> options);

    @Headers({
            "hm-app: HMA",
            "hm-app-v: 3.5.1",
            "hm-app-m: Prod",
            "hm-app-c: UMeng",
            "hmyd-app-timestamp: 1552405982080"
    })
    @GET("app/user/v1/login")
//    Observable<UserInfo> loginWithRxJava(@QueryMap Map<String, String> options);
    Observable<UserInfo> loginWithRxJava(@Query("username") String username, @Query("password") String password );


    @POST(UrlConstant.REGISTER)
    Observable<UserInfo> register(@Body Register register);
}
